package daobeauty.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.Query;


/**
 * This interface is a template for all available functionality of daobeauty.
 * Not all functions are implemented for now.
 * TODO create javadocs for this one
 * 
 * Created 18.04.2008
 * @author M. Serhat Cinar
 */
public interface Dao<D, PK extends Serializable> extends SessionFactoryAware{
	// domain
	/**
	 * Returns the domain class of this DAO.
	 * 
	 * @return domain class of this DAO
	 */
	public Class<? extends D> getDomain(); // implemented, tested
	
	
	public Class<? extends Serializable> getPrimaryKey(); // implemented, tested
	
	// primary key
	public PK findByPrimaryKey(Serializable id); // implemented, tested
	public PK findById(Serializable id); // implemented, tested
	
	// crud
	public void saveOrUpdate(D d); // implemented
	public void saveOrUpdate(Collection<D> d); // implemented
	public void saveOrUpdate(D [] d); // implemented
	
	public void save(D d); // implemented, tested
	public void save(Collection<D> d); // implemented
	public void save(D [] d); // implemented
	
	public void update(D d); // implemented, tested
	public void update(Collection<D> d); // implemented
	public void update(D [] d); // implemented
	
	public void delete(D d); // implemented
	public void delete(Collection<D> d); // implemented
	public void delete(D [] d); // implemented
	
	// by example
	public List<D> findByExample(D example); // implemented, tested
	public List<D> findByExample(D example, Sorting sorting); // implemented, tested
	public List<D> findByExample(D example, Sorting sorting, Limiting limit); // implemented, tested
	public List<D> findByExample(D example, Limiting limit); // implemented, tested
	
	// named query
	public Query getNamedQuery(String name); // implemented, tested
	
	// criteria
	public Criteria createCriteria(); // implemented, tested
	
	// finders. returntyp kann auch array sein
	
	// findAll
	public List<D> findAll(); // implemented
	public List<D> findAll(Sorting sorting); // implemented
	public List<D> findAll(Limiting limit); // implemented
	public List<D> findAll(Sorting sorting, Limiting limit); // implemented
	
	public List<D> findAll(String hqlQuery); // implemented
	public List<D> findAll(String hqlQuery, Limiting limit); // implemented
	public List<D> findAll(String hqlQuery, Object parameter); // implemented
	public List<D> findAll(String hqlQuery, Object parameter, Limiting limit); // implemented
	public List<D> findAll(String hqlQuery, Object parameter1, Object parameter2); // implemented
	public List<D> findAll(String hqlQuery, Object parameter1, Object parameter2, Limiting limit); // implemented
	
	public List<D> findAll(String hqlQuery, Object[] values); // implemented
	public List<D> findAll(String hqlQuery, Object[] values, Limiting limit); // implemented
	
	public List<D> findAll(String hqlQuery, Collection values); // implemented
	public List<D> findAll(String hqlQuery, Collection values, Limiting limit); // implemented
	
	public List<D> findAll(String hqlQuery, Map valuesByName); // implemented
	public List<D> findAll(String hqlQuery, Map valuesByName, Limiting limit); // implemented
	
	// findAllByNative
	
	public List<D> findByNativeQuery(String sql); // implemented, tested
	public List<D> findByNativeQuery(String sql, Limiting limit); // implemented
	
	public List<D> findByNativeQuery(String sql, Object[] values); // implemented, tested
	public List<D> findByNativeQuery(String sql, Object[] values, Limiting limit); // implemented
	
	public List<D> findByNativeQuery(String sql, Collection values); // implemented
	public List<D> findByNativeQuery(String sql, Collection values, Limiting limit); // implemented
	
	public List<D> findByNativeQuery(String sql, Map valuesByName); // implemented, tested
	public List<D> findByNativeQuery(String sql, Map valuesByName, Limiting limit); // implemented
	
	// findCountByExample
	public long findCountByExample(D example);
	
	// findCountAll
	public long findCountAll(String hqlQuery, Object[] values);
	public long findCountAll(String hqlQuery, Collection values);
	public long findCountAll(String hqlQuery, Map valuesByName);
	public long findCountAll(String hqlQuery);
	
	// findSumByExample
	public long findSumByExample(Object example);
	
	// findSumAll
	public long findSumAll(String hqlQuery, Object[] values);
	public long findSumAll(String hqlQuery, Collection values);
	public long findSumAll(String hqlQuery, Map valuesByName);
	public long findSumAll(String hqlQuery);
	// TODO all projections:
	// AggregateProjection 	avg(String propertyName)
	// CountProjection 	count(String propertyName)
	// CountProjection 	countDistinct(String propertyName)
	// Projection 	distinct(Projection proj)
	// PropertyProjection 	groupProperty(String propertyName)
	// AggregateProjection 	max(String propertyName)
	// AggregateProjection 	max(String propertyName)
	// AggregateProjection 	min(String propertyName)
	// AggregateProjection 	sum(String propertyName)
	
	// TODO findSumBy..., findCountBy...
	// TODO scrollableresultsets
}